<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <title>物流公司</title>
    <!-- Bootstrap core CSS -->
    <link href="../bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<nav th:replace="~{front/log/log_topbar::top}"></nav>
<div class="container" style="margin-top: 80px">
    <!-------------------------------------公司搜索框---------------------------------------------------------------->
    <div style="display: inline-block;margin-left: 20px;margin-bottom: 20px">
        <form method="post" action="/company_list_search">
            <label style="color: #fa5000;">公司搜索:</label>
            <div class="row form-group" style="display: inline-block; margin-bottom: 0;margin-left: 10px">
                <label class="sr-only" for="companyName">companyName</label>
                <input type="text" class="form-control" id="companyName" name="companyName" placeholder="输入公司关键字">
            </div>
            <div style="display:inline-block;margin-left:20px;"><button id="search1" style="background:#fa5000;height:35px" type="submit" class="btn btn-warning btn-sm">公司查找</button></div>
        </form>
    </div>
    <!-------------------------------------公司搜索框---------------------------------------------------------------->

    <div style="margin-top: 5px;margin-bottom: 25px; background-color: #fa5000;width: 1140px;height: 1px;"></div>

    <div id="resultContent"></div>
    <!-------------------------------------列表---------------------------------------------------------------->
    <div th:each="company:${pageDTO.result}">
        <div class="row" style="margin-top: 15px; border-bottom: dashed 1px #dddddd;">
            <div class="col-md-5" style="height: 90px;">
                <p>
                    <a th:href="@{'/com_detail_material?companyName='+${company.companyName}}" target="_blank" style="text-decoration: none;"><span id="comName" style="font-size: 18px; color: #fa5000; font-weight: bold;" th:text="${company.companyName}"></span></a>
                </p>
                <p>
                    <i style="font-style: normal; color: #999999">所在地: </i>
                    <span style="font-weight: bold; color: black;" th:text="${company.addressProvince}+${company.addressCity}"></span>
                </p>
                <p>
                    <i style="font-style: normal; color: #999999">地址: </i>
                    <span style="font-weight: bold; color: black;" th:text="${company.addressReal}"></span>
                </p>
            </div>
            <div class="col-md-4" style="height: 90px;">
                <p style="margin-top:33px;">
                    <i style="font-style: normal; color: #999999">联系人: </i>
                    <span style="font-weight: bold; color: black;" th:text="${company.corporation}"></span>
                </p>
                <p>
                    <i style="font-style: normal; color: #999999">联系电话: </i>
                    <span style="font-weight: bold; color: black;" th:text="${company.phoneNumber}"></span>
                </p>
            </div>
            <div class="col-md-3" style="height: 90px;">
                <p style="margin-top: 23px">
                    <a style="text-decoration: none;" target="_blank" th:href="@{'/com_detail_material?companyName='+${company.companyName}}"><button style="background:#fa5000;border-color: #fa5000;" type="submit" class="btn btn-warning">查看</button></a>
                </p>
            </div>
        </div>
    </div>
    <!-------------------------------------列表---------------------------------------------------------------->
    <nav aria-label="Page navigation" id="pageNav">
        <ul class="pagination">
            <li><a th:href="@{'/logisticsPlatform/company_list_all?page=1'}">首页</a></li>
            <li th:unless="${pageDTO.page.hasPrevious()}" class="disabled">
                <a aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            <li th:if="${pageDTO.page.hasPrevious()}">
                <a aria-label="Previous" th:href="@{'/logisticsPlatform/company_list_all?page='+${pageDTO.page.getCurrent()-1}}">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            <li><span th:text="'第 '+${pageDTO.page.getCurrent()}+' 页/共 '+${pageDTO.page.getPages()}+' 页 '"></span></li>
            <li th:unless="${pageDTO.page.hasNext()}" class="disabled">
                <a aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
            <li th:if="${pageDTO.page.hasNext()}">
                <a href="#" aria-label="Next" th:href="@{'/logisticsPlatform/company_list_all?page='+${pageDTO.page.getCurrent()+1}}">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
            <li><a th:href="@{'/logisticsPlatform/company_list_all?page='+${pageDTO.page.getPages()}}">末页</a></li>
        </ul>
    </nav>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../jquery-3.3.1.js"></script>
<script src="../bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script>
    $(function () {
        $("#p1").removeClass("active");
        $("#p2").removeClass("active");
        $("#p3").removeClass("active");
        $("#p4").addClass("active");
    })
</script>

<script>
    $(function () {
        var pageNum = [[${pageDTO.page.getPages()}]];
        console.log(pageNum);
        if (pageNum === 0){
            notFoundContent();
        }
    });

    function notFoundContent() {
        document.getElementById("pageNav").remove();
        document.getElementById("resultContent").innerHTML = "<div class=\"col-md-12\" style=\"height: 90px;\">" +
            "                <p>" +
            "                    <h2 style=\"text-align: center; font-style: normal; color: #444\">暂时没有搜到符合您查询条件的公司</h2>"+
            "                </p>" +
            "            </div>";
    }
</script>

</body>
</html>